package com.woniuxy.exchangeType.topic;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;
import com.woniuxy.utils.Utils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class TopicProducer {
    public static void main(String[] args) throws IOException, TimeoutException {
        //获取连接
        Connection connection = Utils.getConnection();
        //对接通道
        Channel channel = connection.createChannel();
        //绑定队列 发送消息  并消息持久化
        channel.basicPublish("topicExchange","one.topic.two", MessageProperties.PERSISTENT_TEXT_PLAIN,"建立主题订阅模型:one.topic.two".getBytes());
        channel.basicPublish("topicExchange","topic.three",MessageProperties.PERSISTENT_TEXT_PLAIN,"建立主题订阅模型:topic.three".getBytes());
        channel.basicPublish("topicExchange","topic.topic.five",MessageProperties.PERSISTENT_TEXT_PLAIN,"建立主题订阅模型:topic.topic.five".getBytes());
        System.out.println("生产者发送消息");
        channel.close();
        connection.close();

    }
}
